package com.test;


import com.model.user;
import com.web.action.userAction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class lesson4 {


    @Test
    public void test2() throws Exception{

        ApplicationContext context = new ClassPathXmlApplicationContext("bean4.xml");

//        userService service = (userService) context.getBean("userService");
//
//        user user1 = new user();
//        user1.setUserName("ahah");
//        user1.setPassword("sshsh");
//        service.add(user1);
        userAction userAction = context.getBean(userAction.class);
        //userAction userAction = (userAction) context.getBean("userAction");
        //userAction action = context.getBean("userAction");
        user user = new user();
        user.setUserName("ahaha");
        user.setPassword("kakaka");
        userAction.save(user);
        userAction userAction2 = context.getBean(userAction.class);
        System.out.println(userAction);
        System.out.println(userAction2);

        context.getClass().getMethod("close").invoke(context);
    }
}
